define(["jquery","bbcare","as/app/growth/growthDetail.servers","as/app/growth/growthDetail.ui","as/app/growth/growthDetail.event"],
	function($,$bb,$servers,$ui,$event){
	var growthDetail = {};

	/**
	 * 请求历史记录成功后的回调函数
	 */
	var ajaxRecordHistoryCallBack = function(data,params){
		if( data.rows && data.rows.length > 0 ){
			// 顶部颜色
			var className = data.rows[0].gender == "F" ? "girlBg" : "boyBg";
			$(".panel-heading").addClass(className);
			// 历史记录初始化
			$ui.history({
				"id":"growingHistory",
				"list":data.rows
			});
			$("#growingHistory li").unbind("click");
			$("#growingHistory li").data("params",params);
			$("#growingHistory li").click($event.onRecordSelect);
			// 找到传递过来的记录id并点击
			var index = $servers.getDefaultIndex(data.rows,params.recordId);
			$("#growingHistory li").eq(index).click();
		}
	}

	growthDetail.init = function(){
		var params = $bb.getPageParams();
	    $servers.ajaxRecordHistory(params,ajaxRecordHistoryCallBack);
	}

	return growthDetail;
});